package com.tedu.jsd2407_ivos_fzj.dict.controller;

import com.tedu.jsd2407_ivos_fzj.base.response.JsonResult;
import com.tedu.jsd2407_ivos_fzj.dict.pojo.dto.DictParam;
import com.tedu.jsd2407_ivos_fzj.dict.pojo.dto.DictQuery;
import com.tedu.jsd2407_ivos_fzj.dict.pojo.vo.DictVO;
import com.tedu.jsd2407_ivos_fzj.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/v1/dict")
@RestController
@Slf4j
public class DictController {
    @Autowired
    private DictService dictService;
    @GetMapping("/select")
    public JsonResult select(DictQuery dictQuery){
        log.debug("查询，参数：{}",dictQuery);
        List<DictVO> dictVOList = dictService.select(dictQuery);
        return JsonResult.ok(dictVOList);
    }
    @PostMapping("/save")
    public JsonResult save(DictParam dictParam){
        log.debug("保存，参数：{}",dictParam);
        dictService.save(dictParam);
        return JsonResult.ok();
    }
    @PostMapping("/deleteById/{id}")
    public JsonResult deleteById(@PathVariable Long id){
        log.debug("删除，参数：{}",id);
        dictService.deleteById(id);
        return JsonResult.ok();
    }
}
